package com.songcha.module_mine.ui.activity.userinfo

import com.songcha.library_base.mvvm.base.BaseRepository
import com.songcha.library_network.bean.BaseBean
import com.songcha.library_network.bean.BaseStringDataBean
import com.songcha.module_mine.api.MineApiManager
import com.songcha.module_mine.bean.OssParamsBean
import io.reactivex.Observable
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject
import retrofit2.Call
import java.util.concurrent.Callable

class UserInfoRepository:BaseRepository() {
    fun modifyUserNickName(nickName:String,userId:Int):Observable<BaseBean>{
        val json=JSONObject().apply {
            put("userNick",nickName)
            put("id",userId)
        }
        return MineApiManager.api.modifyUserInfo(json.toString().toRequestBody())
    }

    fun modifyUserAvatar(avatar:String,userId:Int):Observable<BaseBean>{
        val json=JSONObject().apply {
            put("avatar",avatar)
            put("id",userId)
        }
        return MineApiManager.api.modifyUserInfo(json.toString().toRequestBody())
    }

    fun getOssParams():Observable<OssParamsBean>{
        return MineApiManager.api.getOssParams()
    }

    fun getOssSign(content:String): Observable<BaseStringDataBean> {
        val json = JSONObject().apply{
            put("content",content)
        }
        return MineApiManager.api.getOssSign(json.toString().toRequestBody())
    }


}